• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

202
Vistas
DisTubeError [INVALID_TYPE]: Expected 'number' for 'volume', but got '50' discord.js V13

I am trying to make a Discord music bot. All the code work fine but in the Volume command, I get this error when I execute !volume 50 :

throw new __1.DisTubeError("INVALID_TYPE", "number", volume, "volume");
                  ^
DisTubeError [INVALID_TYPE]: Expected 'number' for 'volume', but got '50'

This is my code :

const { guild, channel, member } = message;
if (
  member.roles.cache.has('926674590200123502') ||
  member.roles.cache.has('945435842258808862') ||
  member.roles.cache.has('928717168001024020') ||
  member.roles.cache.has('935939126123974726') ||
  member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)
) {
  const voicechannel = member.voice.channel;

  if (!voicechannel)
    return message.reply(
      'You must be in a voice channel to use Music commands',
    );

  if (guild.me.voice.channelID && voicechannel.id !== guild.me.voice.channelID)
    return message.reply(
      `I am already playing music in <#${guild.me.voice.channelID}>`,
    );

  const volume = args[0];

  if (volume > 100 || volume < 1)
    return message.reply('the volume must be a number between 1 and 100');

  await client.distube.setVolume(voicechannel, volume);
  await message.reply(`🔊 volume set to ${volume}`);
} else return message.reply("You can't use this command");

about 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's because '50' is not a number but a string. Try to parse it first:

const volume = parseInt(args[0], 10);

if (isNaN(volume)) 
  return message.reply('Volume must be a valid number');
if (volume > 100 || volume < 1 )
  return message.reply('Volume must be a number between 1 and 100');
about 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda